<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<form id="frmLogin">
			<label>用户名</label>
			<input  type="text" name="username" placeholder="请输入用户名" required/><br>
			<label>密码</label>
			<input  type="password" name="password" placeholder="请输入密码" required/><br>
			<button type="submit">登录</button>
			
		</form>
	</body>
</html>
<script src="js/jquery-3.6.4.min.js"></script>
<script>
	$(document).ready(function(){
		$("#frmLogin").submit(function(){
			//console.info($("#frmLogin").serialize());
			$.post("http://localhost:9999/user/login",$("#frmLogin").serialize(),function(rs){
				//console.info(rs);
				if(rs.code==0){
					//将登录用户的信息记录在本地数据存储中
					sessionStorage.setItem("userInfo",JSON.stringify(rs.data))
					
					//进行页面跳转
					$(location).attr("href","index.html")
					
				}else{
					//登录失败
					alert(rs.message)
				}
				
			},"json");
			
			return false;
		});
		
	});
	
</script>